from rest_framework import serializers
from drf_haystack.serializers import HaystackSerializer
from goods.search_indexes import SKUIndex
from goods.models import SKU


class SKUSSerializers(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields = '__all__'


class SKUSearchSeializer(HaystackSerializer):

    # 返回的字段 参与序列化返回
    object = SKUSSerializers(read_only=True)

    class Meta:
        index_classes = [SKUIndex] # 制定索引类
        fields = ('text','object') # 制定那些字段返回
